<template>
    <section>
        <!-- 搜索 -->
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
    <el-tab-pane label="未审核" name="first">
          <!-- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.name" placeholder="商品名"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getshops">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="handleAdd">新增</el-button>
				</el-form-item>
			</el-form>
    </el-col> -->
    <el-table :data="shops" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
            <el-table-column prop="cs_img" label="商品图" width="120" sortable>
                
                 <template   slot-scope="scope">            
                    <img :src="scope.row.cs_img"  min-width="80" height="80" />
                 </template>         

			</el-table-column>
			<el-table-column prop="c_name" label="商品名" width="120" sortable>
			</el-table-column>
			<el-table-column prop="c_price" label="商品价格" width="80" sortable>
			</el-table-column>
			<el-table-column prop="c_detailes" label="商品详情" width="300" sortable>
			</el-table-column>
            <el-table-column prop="c_targetmoney" label="目标金额" width="80" sortable>
			</el-table-column>
            <el-table-column prop="max_yield" label="最大数量" width="80" sortable>
			</el-table-column>
            <el-table-column prop="startday" label="开始日期" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_day" label="结束日期" width="80" sortable>
			</el-table-column>
			<el-table-column label="操作" width="150">
				<template  scope="scope">
					<el-button size="small" @click="pass(scope.row.c_id)" >
                        {{scope.row.status}}</el-button>
				</template>
			</el-table-column>
		</el-table>
        <el-col :span="24" class="toolbar">
			<!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
			<el-pagination 
            layout="total, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange" 
            :page-size="pagesize"
            :current-page=1
            :total="total" 
            style="float:right;">
			</el-pagination>
		</el-col>
    </el-tab-pane>





    <el-tab-pane label="即将上线" name="fived">
          <!-- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.name" placeholder="姓名"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getshops">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="handleAdd">新增</el-button>
				</el-form-item>
			</el-form>
    </el-col> -->
    <el-table :data="jjcrowd" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
            <el-table-column prop="cs_img" label="商品图" width="120" sortable>
                
                 <template   slot-scope="scope">            
                    <img :src="scope.row.cs_img"  min-width="80" height="80" />
                 </template>         

			</el-table-column>
			<el-table-column prop="c_name" label="商品名" width="120" sortable>
			</el-table-column>
			<el-table-column prop="c_price" label="商品价格" width="80" sortable>
			</el-table-column>
			<el-table-column prop="c_detailes" label="商品详情" width="300" sortable>
			</el-table-column>
            <el-table-column prop="c_targetmoney" label="目标金额" width="80" sortable>
			</el-table-column>
            <el-table-column prop="max_yield" label="最大数量" width="80" sortable>
			</el-table-column>.
            <el-table-column prop="startday" label="开始日期" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_day" label="结束日期" width="80" sortable>
			</el-table-column>
		</el-table>
        <el-col :span="24" class="toolbar">
			<!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
			<el-pagination 
            layout="total, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange" 
            :page-size="pagesize"
            :current-page=1
            :total="jjtotal" 
            style="float:right;">
			</el-pagination>
		</el-col>
    </el-tab-pane>
    <el-tab-pane label="众筹中" name="second">
          <!-- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.name" placeholder="姓名"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getshops">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="handleAdd">新增</el-button>
				</el-form-item>
			</el-form>
    </el-col> -->
    <el-table :data="zong" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
            <el-table-column prop="cs_img" label="商品图" width="120" sortable>
                
                 <template   slot-scope="scope">            
                    <img :src="scope.row.cs_img"  min-width="80" height="80" />
                 </template>         

			</el-table-column>
			<el-table-column prop="c_name" label="商品名" width="120" sortable>
			</el-table-column>
			<el-table-column prop="c_price" label="商品价格" width="80" sortable>
			</el-table-column>
			<el-table-column prop="c_detailes" label="商品详情" width="300" sortable>
			</el-table-column>
            <el-table-column prop="c_targetmoney" label="目标金额" width="80" sortable>
			</el-table-column>
            <el-table-column prop="max_yield" label="最大数量" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_arrive" label="已筹" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_support" label="支持人数" width="80" sortable>
			</el-table-column>
 <el-table-column label="是否热门" width="150">
				<template  scope="scope">
					<el-button size="small" @click="remena(scope.row.c_id,scope.row.c_remen)" >
                        {{scope.row.remen}}</el-button>
				</template>
			</el-table-column>
		</el-table>
        <el-col :span="24" class="toolbar">
			<!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
			<el-pagination 
            layout="total, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange" 
            :page-size="pagesize"
            :current-page=1
            :total="zctotal" 
            style="float:right;">
			</el-pagination>
		</el-col>
    </el-tab-pane>

    <el-tab-pane label="众筹成功" name="third"> 
         <el-table :data="success" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
            <el-table-column prop="cs_img" label="商品图" width="120" sortable>
                
                 <template   slot-scope="scope">            
                    <img :src="scope.row.cs_img"  min-width="80" height="80" />
                 </template>         

			</el-table-column>
			<el-table-column prop="c_name" label="商品名" width="120" sortable>
			</el-table-column>
			<el-table-column prop="c_price" label="商品价格" width="80" sortable>
			</el-table-column>
			<el-table-column prop="c_detailes" label="商品详情" width="300" sortable>
			</el-table-column>
            <el-table-column prop="c_targetmoney" label="目标金额" width="80" sortable>
			</el-table-column>
            <el-table-column prop="max_yield" label="最大数量" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_arrive" label="已筹" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_support" label="支持人数" width="80" sortable>
			</el-table-column>
		</el-table>
        <el-col :span="24" class="toolbar">
			<!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
			<el-pagination 
            layout="total, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange" 
            :page-size="pagesize"
            :current-page=1
            :total="cgtotal" 
            style="float:right;">
			</el-pagination>
		</el-col>
    </el-tab-pane>
    <el-tab-pane label="众筹失败" name="fourth">
 <el-table :data="fail" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
            <el-table-column prop="cs_img" label="商品图" width="120" sortable>
                
                 <template   slot-scope="scope">            
                    <img :src="scope.row.cs_img"  min-width="80" height="80" />
                 </template>         

			</el-table-column>
			<el-table-column prop="c_name" label="商品名" width="120" sortable>
			</el-table-column>
			<el-table-column prop="c_price" label="商品价格" width="80" sortable>
			</el-table-column>
			<el-table-column prop="c_detailes" label="商品详情" width="300" sortable>
			</el-table-column>
            <el-table-column prop="c_targetmoney" label="目标金额" width="80" sortable>
			</el-table-column>
            <el-table-column prop="max_yield" label="最大数量" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_arrive" label="已筹" width="80" sortable>
			</el-table-column>
            <el-table-column prop="c_support" label="支持人数" width="80" sortable>
			</el-table-column>

			
				
		</el-table>
        <el-col :span="24" class="toolbar">
			<!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
			<el-pagination 
            layout="total, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange" 
            :page-size="pagesize"
            :current-page=1
            :total="sbtotal" 
            style="float:right;">
			</el-pagination>
		</el-col>

    </el-tab-pane>
  </el-tabs>
  
    </section>
</template>

<script>
export default {
data () {
    return {
        filters:{
            name:""
        },
        shops:[],
        page:1,
        listLoading:false,
        sels:[],
        pagesize:10,
        total:0,
        size:6,
         dialogFormVisible: false,
          activeName: 'first',
          jjcrowd:"",
          zong:"",
          crowd:[],
          hhh:[],
          success:[],
          fail:[],
          jjtotal:0,
          zctotal:0,
          cgtotal:0,
          sbtotal:0

    }
},
created () {
    
},
methods: {
      // 获取用户列表
    getshops()
    {
        console.log(this.filters.name)
        
        let para = {
					page: this.page,
                    limit:this.pagesize,
                    name:this.filters.name,
                    data:new Date().getTime()
                };
             
                this.listLoading = true;
        this.$axios.post("http://127.0.0.1:8081/admin/crowdmsg",para)
        .then(res=>
        {
            console.log("res.data.data",res.data)
            this.shops=res.data.data;
            this.total=res.data.count
            this.jjcrowd=res.data.jjcrowd;
            this.zong=res.data.suoyou;
            this.success=res.data.success;
            this.fail=res.data.fail;
            this.jjtotal=this.jjcrowd.length;
            console.log(res.data.suoyou)
            console.log(this.zong)
            // console.log()
            // console.log("data",typeof(this.shops))
            // console.log("jjjj",typeof(this.jjcrowd))
            this.listLoading = false;
            for(let n=0;n<this.jjcrowd.length;n++)
            {
                this.jjcrowd[n].startday=new Date(parseInt(this.jjcrowd[n].startday)).toJSON().substr(0, 10).replace('T', ' ');
                
            }
            for(let i=0;i<this.shops.length;i++)
            {
                this.shops[i].startday=new Date(parseInt(this.shops[i].startday)).toJSON().substr(0, 10).replace('T', ' ');
                this.shops[i].status="点击通过审核";
            }
            // console.log(this.zong.length)
            for(let j=0;j<this.zong.length;j++)
            {
                  this.zong[j].startday=new Date(parseInt(this.zong[j].startday)).toJSON().substr(0, 10).replace('T', ' ')
                
                    if(this.zong[j].c_remen==0)
                    {
                        this.zong[j].remen="否"
                    }
                    else{
                        this.zong[j].remen="是"
                    }
                
            }
            this.cgtotal=this.success.length;
            this.zctotal=this.zong.length;
            this.sbtotal=this.fail.length;

            // console.log(res.data.data);
            //  console.log("user",this.shops);
        })
       
        
    },
    handleAdd()
    {
        console.log("添加");
    },
    submitForm(id,ids,ii)
    {
        console.log(id)
    },
    selsChange(sels)
    {
        console.log(sels)
        this.sels=sels;
    },
    formatSex(row,column)
    {
        return row.u_sex == 2 ? '男' : row.u_sex == 1 ? '女' : '未知';
    },
    formatsy(row,column)
    {
        return row.p_stock > 0 ? '剩余'+row.p_stock+'件': '已售罄';
    },
    handleEdit(index,row)
    {
        // console.log("编辑");
    },
    handleDel(index,row)
    {
        let id=row.p_id;
        // console.log("删除");
        this.$confirm("确认删除选中记录吗？","提示",{
            type: 'warning'
        }).then(()=>
        {
            
            this.listLoading=true;
            let para={p_id:id};
            // para=names;
            this.$axios.post("http://127.0.0.1:8081/admin/delgoods",para).then(res=>
            {
                this.listLoading=false;
                let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"success"
                })
                this.getshops();
            })
           
        }).catch(()=>
        {

        })
    },
    batchRemove()
    {
        let p_id=this.sels.map(item => item.p_id).toString();
        this.$confirm("确认删除选中记录吗？","提示",{
            type: 'warning'
        }).then(()=>
        {
            
            this.listLoading=true;
            let para={p_id:p_id};
            // para=names;
            this.$axios.post("http://127.0.0.1:8081/admin/delgoods",para).then(res=>
            {
                this.listLoading=false;
                let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"success"
                })
                this.getshops();
            })
           
        }).catch(()=>
        {

        })
    },
    handleCurrentChange(val)
    {
        // console.log("val",val);
        this.page = val;
		this.getshops();
    },
    handleSizeChange(val)
    {
        this.page = val;
		this.getshops();
    },
    handleClick(tab, event) {
        console.log(tab, event);
      },
      pass(id)
      {
          this.$confirm("确认通过审核？","提示",{
            type: 'warning'
        }).then(()=>
        {
            
            this.listLoading=true;
            let para={c_id:id};
            // para=names;
            this.$axios.post("http://127.0.0.1:8081/admin/updatecrowdstatus",para).then(res=>
            {
                this.listLoading=false;
                if(res.data.status==1)
                {
                    let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"success"
                })
                }
                else{
                    let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"info"
                })
                }
                
                this.getshops();
            })
           
        }).catch(()=>
        {

        })
      },
      remena(c_id,status)
      {
          let c_remen="";
          console.log(c_id,status);
          if(status==0)
          {
              c_remen=1;
              this.$confirm("确认此商品上热门？","提示",{
            type: 'warning'
        }).then(()=>
        {
 this.$axios.post("http://127.0.0.1:8081/admin/updateremen",{
     c_id:c_id,
     c_remen:c_remen}).then(res=>
            {
                 this.listLoading=false;
                if(res.data.status==1)
                {
                    let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"success"
                })
                }
                else{
                    let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"info"
                })
                }
                
                this.getshops();
            })
        }



        ).catch(()=>
        {
        })
          }
          else{
               c_remen=0;
              this.$confirm("确认取消热门？","提示",{
            type: 'warning'
        }).then(()=>
        {
this.$axios.post("http://127.0.0.1:8081/admin/updateremen",{
     c_id:c_id,
     c_remen:c_remen}).then(res=>
            {
                this.listLoading=false;
                if(res.data.status==1)
                {
                    let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"success"
                })
                }
                else{
                    let ress=res.msg
                this.$message({
                    message:res.data.msg,
                    type:"info"
                })
                }
                
                this.getshops();
            })
        }

 

        ).catch(()=>
        {

        })
          }
      }
},
mounted () {
    this.getshops();
}
}
</script>

<style>
.el-table_1_column_5  .cell{
    text-align: center;
    /* color: red; */
}
</style>
